<?php
	class khuenthuong_kyluatdb
	{
		public function Add($MaHocSinh,$NamHoc,$Loai,$LyDo,$NgayQuyetDinh,$GhiChu,$HocKy)
		{
			$sql = " INSERT INTO `tbl_khenthuong_kyluat`(`MaHocSinh`, `NamHoc`, `Loai`, `LyDo`, `NgayQuyetDinh`, `GhiChu`, `HocKy`) VALUES ('$MaHocSinh','$NamHoc',$Loai,".dataservice::slashes($LyDo).",'$NgayQuyetDinh','$GhiChu','$HocKy')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaHocSinh,$NamHoc,$HocKy)
		{
			$sql = "DELETE FROM `tbl_khenthuong_kyluat` WHERE MaHocSinh = '$MaHocSinh' AND NamHoc = '$NamHoc' AND HocKy = '$HocKy' ";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaHocSinh,$NamHoc,$Loai,$LyDo,$NgayQuyetDinh,$GhiChu,$HocKy)
		{
			$sql = "UPDATE `tbl_khenthuong_kyluat`
			 		SET Loai = '$Loai',
						LyDo = '$LyDo',
						GhiChu = '$GhiChu'			 	
				 WHERE MaHocSinh = '$MaHocSinh' MaHocSinh = '$MaHocSinh' AND NamHoc = '$NamHoc' AND HocKy = '$HocKy' "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		
	
		public function GetList($MaHocSinh,$NamHoc,$Loai,$LyDo,$GhiChu,$HocKy)
		{
			$sql = "SELECT * FROM `tbl_khenthuong_kyluat` WHERE 1";
			if($MaHocSinh!="")
				$sql .= " AND MaHocSinh = '$MaHocSinh' ";
			if($Loai!="")
				$sql .= " AND Loai = $Loai ";
			if($GhiChu!="")
				$sql .= " AND GhiChu = '$GhiChu' ";
			if($NamHoc!="")
				$sql .= " AND NamHoc = '$NamHoc' ";
			if($HocKy!="")
				$sql .= " AND HocKy = '$HocKy' ";
			if($LyDo!="")
				$sql .= " AND LyDo = '$LyDo' ";
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		public function Find($MaHocSinh,$NamHoc,$Loai,$LyDo,$GhiChu,$HocKy)
		{
			$sql = "SELECT * FROM `tbl_khenthuong_kyluat` WHERE 1";
			if($MaHocSinh!="")
				$sql .= " AND MaHocSinh = '$MaHocSinh' ";
			if($Loai!="")
				$sql .= " AND Loai = $Loai ";
			if($GhiChu!="")
				$sql .= " AND GhiChu LIKE '%$GhiChu%' ";
			if($NamHoc!="")
				$sql .= " AND NamHoc = '$NamHoc' ";
			if($HocKy!="")
				$sql .= " AND HocKy = '$HocKy' ";
			if($LyDo!="")
				$sql .= " AND LyDo LIKE '%$LyDo%' ";			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>